package com.javabi.htmlbuilder.css.border;

import com.javabi.htmlbuilder.HTMLColor;
import com.javabi.htmlbuilder.css.CSSBuilder;
import com.javabi.htmlbuilder.css.CSSDeclaration;
import com.javabi.htmlbuilder.css.CSSPropertyName;
import com.javabi.htmlbuilder.css.unit.CSSUnitNumber;

/**
 * A Border.
 */
public class Border implements CSSDeclaration {

	/** The width. */
	private final CSSUnitNumber width;
	/** The style. */
	private final BorderStyle style;
	/** The color. */
	private final HTMLColor color;

	/**
	 * Creates a new border.
	 * @param width the width.
	 * @param style the style.
	 * @param color the color.
	 */
	public Border(CSSUnitNumber width, BorderStyle style, HTMLColor color) {
		if (width == null || style == null || color == null) {
			throw new NullPointerException();
		}
		this.width = width;
		this.style = style;
		this.color = color;
	}

	/**
	 * Returns the width.
	 * @return the width.
	 */
	public CSSUnitNumber getWidth() {
		return width;
	}

	/**
	 * Returns the style.
	 * @return the style.
	 */
	public BorderStyle getStyle() {
		return style;
	}

	/**
	 * Returns the color.
	 * @return the color.
	 */
	public HTMLColor getColor() {
		return color;
	}

	/**
	 * Returns the CSS property name.
	 * @return the CSS property name.
	 */
	public CSSPropertyName getPropertyName() {
		return CSSPropertyName.BORDER;
	}

	/**
	 * Append this to the given CSS builder.
	 * @param css the CSS builder.
	 * @return the CSS builder.
	 */
	public CSSBuilder appendTo(CSSBuilder css) {
		css.property(getPropertyName());
		width.appendTo(css);
		css.space();
		css.append(style.getValue());
		css.space();
		css.color(color);
		return css;
	}

}
